package com.song.dao.impl;

import com.song.bean.Grade;
import com.song.dao.GradeDao;
import com.song.dao.Utils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


public class GradeDaoImpl extends Utils implements GradeDao {
    @Override
    public List getGrade() {
        List<Grade> gradeList = new ArrayList<>();
        try {
            String sql = "select * from grade";
            ResultSet select = select(sql, null);
            while (resultSet.next()) {
                Grade grade = new Grade();
                grade.setGradeid(resultSet.getInt("gradeid"));
                grade.setGradename(resultSet.getString("gradename"));
                gradeList.add(grade);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            close();
        }
        return gradeList;
    }
}
